/*
 * Copyright (c) 2009 Project E7
 *
 * This file is part of ZebBowling
 *
 * ZebBowling is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ZebBowling is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ZebBowling. If not, see <http://www.gnu.org/licenses/>.
 **/

package org.zebbowling.control;

import com.sun.spot.io.j2me.radiogram.Radiogram;

/**
 * A class implements this interface to tell a program what to do with the data
 * recieved from a controller connected on a <code>ControllerConnection</code>
 * Added to the connection via its {@link org.zebbowling.control.ControllerConnection }
 * method. It will also control the activity of the thread it is running on many
 * implementations may not want to ever suspend or stop the thread in which case
 * it is best to just extend the {@link Controller} class and use the default implementation
 * for those methods and only override {@link ControlHandler#handleInput(com.sun.spot.io.j2me.radiogram.Radiogram)}
 *
 * @author Joel Jauregui
 */
public interface ControlHandler {

    /**
     * Checks if this Controller's input is being suspended
     *
     * @return <tt>true</tt> if the input is being supressed else <tt>false</tt>
     */
    public boolean getSuspended();

    /**
     * Sets if this Controller's input should be suspended
     *
     * @param suspend <tt>true</tt> if it should be supressed else false
     */
    public void setSuspened(boolean suspend);

    /**
     * Stops this controller from running
     */
    public void stop();

    /**
     * Returns boolean stating if the thread is dead or not
     *
     * @return <tt>true</tt> if the thread is to die else false
     */
    public boolean threadDead();

    /**
     * Will take the action(s) neccesary depending on the information recieved
     * from the SPOT.
     *
     * @param pkt The packet of infomation regarding the state of the SPOT the
     * packet is organized as follows: switch1(byte), switch2, x tilt(in
     * radians double), y tilt, z tilt, x acceleration (in G's double), y acceleration,
     * and z acceleration.
     */
    public void handleInput(Radiogram pkt);

    }
